package com.red.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.red.common.annotation.Log;
import com.red.common.core.controller.BaseController;
import com.red.common.core.domain.AjaxResult;
import com.red.common.enums.BusinessType;
import com.red.basic.domain.RedGoodsFolder;
import com.red.basic.service.IRedGoodsFolderService;
import com.red.common.utils.poi.ExcelUtil;

/**
 * 物资目录管理Controller
 * 
 * @author bug2222
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/basic/goodsFolder")
public class RedGoodsFolderController extends BaseController
{
    @Autowired
    private IRedGoodsFolderService redGoodsFolderService;

    /**
     * 查询物资目录管理列表
     */
    @PreAuthorize("@ss.hasPermi('basic:goodsFolder:list')")
    @GetMapping("/list")
    public AjaxResult list(RedGoodsFolder redGoodsFolder)
    {
        List<RedGoodsFolder> list = redGoodsFolderService.selectRedGoodsFolderList(redGoodsFolder);
        return success(list);
    }

    /**
     * 导出物资目录管理列表
     */
    @PreAuthorize("@ss.hasPermi('basic:goodsFolder:export')")
    @Log(title = "物资目录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RedGoodsFolder redGoodsFolder)
    {
        List<RedGoodsFolder> list = redGoodsFolderService.selectRedGoodsFolderList(redGoodsFolder);
        ExcelUtil<RedGoodsFolder> util = new ExcelUtil<RedGoodsFolder>(RedGoodsFolder.class);
        util.exportExcel(response, list, "物资目录管理数据");
    }

    /**
     * 获取物资目录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:goodsFolder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(redGoodsFolderService.selectRedGoodsFolderById(id));
    }

    /**
     * 新增物资目录管理
     */
    @PreAuthorize("@ss.hasPermi('basic:goodsFolder:add')")
    @Log(title = "物资目录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RedGoodsFolder redGoodsFolder)
    {
        return toAjax(redGoodsFolderService.insertRedGoodsFolder(redGoodsFolder));
    }

    /**
     * 修改物资目录管理
     */
    @PreAuthorize("@ss.hasPermi('basic:goodsFolder:edit')")
    @Log(title = "物资目录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RedGoodsFolder redGoodsFolder)
    {
        return toAjax(redGoodsFolderService.updateRedGoodsFolder(redGoodsFolder));
    }

    /**
     * 删除物资目录管理
     */
    @PreAuthorize("@ss.hasPermi('basic:goodsFolder:remove')")
    @Log(title = "物资目录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(redGoodsFolderService.deleteRedGoodsFolderByIds(ids));
    }
}
